package com.hosever.designPattern.factoryMethod;
/**
 * 工厂方法模式
 * @author sever ho
 *
 */
public class FactoryMethod {
	
	//简单工厂模式
	public DemoInterface produce(String type){
		if ("1".equals(type)) {  
            return new DemoInterfaceImpl();  
        } else if ("2".equals(type)) {  
            return new DemoInterfaceImpl2();  
        } else {  
            System.out.println("请输入正确的类型!");  
            return null;  
        }  
	}
	
	//多工厂模式
	public DemoInterface getInstance() {
		return new DemoInterfaceImpl();
	}
	
	public DemoInterface getInstance2() {
		return new DemoInterfaceImpl2();
	}
	
	//静态工厂模式
	public static DemoInterface getInstanceStatic() {
		return new DemoInterfaceImpl();
	}
	
	public static DemoInterface getInstance2Static() {
		return new DemoInterfaceImpl2();
	}
}
